<template>
  <div class="container">
    <xy-table ref="table" :api="api" :columns="columns" :param="param">
      <template #view> <span></span></template>
      <template #check> <span></span></template>
      <el-table-column align="center">
        <template slot="addItem" slot-scope="scope">
          <div>
            <el-checkbox
              v-model="param.isShow"
              true-label="1"
              false-label="-1"
              @change="queryChange(scope)"
            ></el-checkbox>
            <!-- <el-switch
              v-model="isShow"
              active-value="1"
              inactive-value="0"
              @change="onChangeShow(scope.row)"
            ></el-switch> -->
            {{ $language.local("isShow") }}
          </div>
        </template>
        <template slot-scope="scope">
          <el-switch
            v-model="scope.row.isShow"
            :active-value="1"
            :inactive-value="0"
            @change="onChangeShow(scope.row)"
          ></el-switch>
        </template>
      </el-table-column>
    </xy-table>
  </div>
</template>

<script>
import API from "../../plugins/api";
export default {
  data() {
    return {
      api: new API("/api/dictionaryType/GetList"),
      columns: {
        typenum: "001",
        name: "发票类型",
        sort: 1,
        remark: "",
      },
      isShow: "1",
      param: {
        isShow: "-1",
      },
    };
  },
  methods: {
    onChangeShow(row) {
      console.log(row);
      this.onEdit(row);
    },
    async onEdit(obj) {
      const response = await this.$http.post("/api/dictionaryType/Edit", obj);
      console.log(response);
    },

    queryChange(...e) {
      console.log(e);
      console.log(this.param.isShow);
      this.$refs.table.getData(this.param);
    },
  },
};
</script>

<style></style>
